<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%--
  Created by IntelliJ IDEA.
  User: Wangzs
  Date: 2018/7/6
  Time: 7:43
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<!-- Content Header (Page header) -->
<section class="content-header" style="">
    <h1>
        ${archives.comName}
        <small>详情信息</small>
    </h1>
    <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> 主页</a></li>
        <li><a href="#">详情信息</a></li>
        <li class="active">${archives.comName}</li>
    </ol>
</section>

<!-- Main content -->
<section class="content">
    <ul class="nav nav-tabs">
        <shiro:lacksRole name="admin">
            <li><a href="#" onclick="loadHref('#archives/archives_user')">档案库</a></li>
        </shiro:lacksRole>
        <shiro:hasAnyRoles name="root,admin">
            <li><a href="#" onclick="loadHref('#archives')">档案库</a></li>
            <li><a href="#"
                   onclick="loadHref('#archives/findByOperateIDView?id=' + ${archives.operateId} + '')">档案库管理</a></li>
        </shiro:hasAnyRoles>

        <li class="active"><a href="#">详情信息</a></li>
    </ul>
    <div class="box">
        <div class="box-body">
            <div class="col-xs-12 col-sm-12">
                <div class="panel panel-default">
                    <div class="panel-heading">企业详情信息</div>
                    <div class="panel-body">
                        <div class="col-md-5">
                            <ul>
                                <li>企业类别：${archives.comTypeSTR}</li>
                                <li>状态：${archives.statusSTR}</li>
                                <li>业务类型：${archives.businessTypeSTR}</li>
                                <li>录入时间：${archives.inputTimeSTR}</li>
                            </ul>
                        </div>
                        <div class="col-md-6">
                            <li>企业名称：${archives.comName}</li>
                            <li>营业执照编号：${archives.businessCode}</li>
                            <li>授信额度：${archives.creditLine}</li>
                            <li>授信期限(年)：${archives.creditLimit}</li>
                        </div>
                        <div class="box-header with-border">
                        </div>
                        <c:forEach items="${archives.tbCompayUploadInfos}" var="tbCompayUploadInfo">
                            <c:if test="${tbCompayUploadInfo.isDisplay==1}">
                                <div class="col-sm-2" id="imageList1">
                                    <c:choose>
                                        <c:when test="${fn:containsIgnoreCase(tbCompayUploadInfo.picUrl, '.png')||fn:containsIgnoreCase(tbCompayUploadInfo.picUrl, '.jpg')||fn:containsIgnoreCase(tbCompayUploadInfo.picUrl, '.jpeg')||fn:containsIgnoreCase(tbCompayUploadInfo.picUrl, '.gif')||fn:containsIgnoreCase(tbCompayUploadInfo.picUrl, '.bmp')}">

                                            <div class="images" style="width:114px; height:210px;">
                                                <img src=${tbCompayUploadInfo.picUrl}
                                                             style="width: 110px; height: 110px;">
                                                <br>
                                                <label>${tbCompayUploadInfo.picName}</label>
                                                <a href="#" onclick='showhtfun("${tbCompayUploadInfo.picUrl}")'>下载</a>
                                            </div>
                                        </c:when>
                                        <c:when test="${empty tbCompayUploadInfo.picUrl}">
                                            <div class="images" style="width:114px; height:210px;">
                                                    <%--<img src=${tbCompayUploadInfo.picUrl}
                                                                 style="width: 110px; height: 110px;">--%>
                                                <br>
                                                <label>${tbCompayUploadInfo.picName}</label>
                                                    <%--<a href="#" onclick='showhtfun("${tbCompayUploadInfo.picUrl}")'>下载</a>--%>
                                            </div>
                                        </c:when>
                                        <c:otherwise>
                                            <div class="images" style="width:114px; height:210px;">
                                                <a target="_blank" href=${tbCompayUploadInfo.picUrl}>下载</a>
                                                <br>
                                                <label>${tbCompayUploadInfo.picName}</label>
                                                    <%--<a href="#" onclick='showhtfun("${tbCompayUploadInfo.picUrl}")'>下载</a>--%>
                                            </div>
                                        </c:otherwise>
                                    </c:choose>
                                </div>
                            </c:if>
                        </c:forEach>
                    </div>
                </div>
                <%-- <div class="panel panel-default">
                     <div class="panel-heading">企业照片</div>
                     <div class="panel-body">

                     </div>
                 </div>--%>
            </div>
            <div class="col-xs-12 col-sm-12">
                <%--担保方--%>
                <c:forEach items="${archivesGuarantees}" var="guarantees">
                <div class="panel panel-default">
                    <div class="panel-heading">担保企业</div>
                    <div class="panel-body">
                        <div class="col-md-12">
                            <ul>
                                <li>类别：${guarantees.comTypeSTR}</li>
                                <li>录入时间：${guarantees.inputTimeSTR}</li>
                                <li>担保人名称：${guarantees.comName}</li>
                                <li>担保金额：${guarantees.creditLine}</li>
                            </ul>
                        </div>

                        <c:forEach items="${guarantees.tbCompayUploadInfos}" var="uploadInfo">
                            <c:if test="${uploadInfo.isDisplay==1}">
                                <div class="col-sm-2" id="imageList1">
                                    <c:choose>
                                        <c:when test="${fn:containsIgnoreCase(uploadInfo.picUrl, '.png')||fn:containsIgnoreCase(uploadInfo.picUrl, '.jpg')||fn:containsIgnoreCase(uploadInfo.picUrl, '.jpeg')||fn:containsIgnoreCase(uploadInfo.picUrl, '.gif')||fn:containsIgnoreCase(uploadInfo.picUrl, '.bmp')}">

                                            <div class="images" style="width:114px; height:210px;">
                                                <img src=${uploadInfo.picUrl}
                                                             style="width: 110px; height: 110px;"></img>
                                                <br>
                                                <label>${uploadInfo.picName}</label>
                                                <a href="#" onclick='showhtfun("${uploadInfo.picUrl}")'>下载</a>
                                            </div>
                                        </c:when>
                                        <c:when test="${empty uploadInfo.picUrl}">
                                            <div class="images" style="width:114px; height:210px;">
                                                    <%--<img src=${uploadInfo.picUrl}
                                                                 style="width: 110px; height: 110px;"></img>--%>
                                                <br>
                                                <label>${uploadInfo.picName}</label>
                                                    <%--<a href="#" onclick='showhtfun("${uploadInfo.picUrl}")'>下载</a>--%>
                                            </div>
                                        </c:when>
                                        <c:otherwise>
                                            <div class="images" style="width:114px; height:210px;">
                                                <a target="_blank" href=${uploadInfo.picUrl}>下载</a>
                                                <br>
                                                <label>${uploadInfo.picName}</label>
                                                    <%--<a href="#" onclick='showhtfun("${uploadInfo.picUrl}")'>下载</a>--%>
                                            </div>
                                        </c:otherwise>
                                    </c:choose>

                                </div>
                            </c:if>
                        </c:forEach>
                    </div>
                </div>
            </div>
            </c:forEach>
        </div>
    </div>
    <!-- /.box -->
</section>
<!-- /.content -->

<div id="img-modal" class="modal fade">
    <div id="img-dialog" class="modal-dialog" style="width: 98%; height: 98%;text-align: center;">
        <div id="img-content" class="modal-content">
            <img id="img-zoom" src="" style="max-height: 100%; max-width: 100%;margin:10px;">
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<!-- /.modal -->

<!-- edit Modal -->
<div class="modal fade" id="updateModal" tabindex="-1" role="dialog" aria-labelledby="updateModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="editModalLabel">证件照片信息</h4>
            </div>
            <div class="modal-body">
                <form id="updateForm" enctype="multipart/form-data">
                    <input type="hidden" name="uploadId" id="upload_id"/>

                    <div class="form-group">
                        <label class="control-label"><span class="asterisk">*</span>上传图片:</label>
                        <input id="input-id1" name="input-id1" type="file" data-show-caption="true">
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" form="updateForm" class="btn btn-primary" id="updateImage"
                <%--data-action="{type:'submit',form:'#updateForm',url:'<%=request.getContextPath()%>/archives/test',after:'$.myAction.refreshContent'}"--%>>
                    确定
                </button>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {

        //点击图片放大
        $("#img-zoom").click(function () {
            $('#img-modal').modal("hide");
        });
        $("#img-dialog").click(function () {
            $('#img-modal').modal("hide");
        });
        //index-list-content为显示文章内容div的class
        $(".images img").each(function (i) {
            var src = $(this).attr("src");
            $(this).click(function () {
                $("#img-zoom").attr("src", src);
                var oImg = $(this);
                var img = new Image();
                img.src = $(oImg).attr("src");
                var realWidth = img.width;//真实的宽度
                var realHeight = img.height;//真实的高度
                var ww = $(window).width();//当前浏览器可视宽度
                var hh = $(window).height();//当前浏览器可视宽度
                $("#img-content").css({"top": 0, "left": 0, "height": "auto"});
                $("#img-zoom").css({"height": "auto"});
                if ((realWidth + 20) > ww) {
                    $("#img-content").css({"width": "100%"});
                    $("#img-zoom").css({"width": "99%"});
                } else {
                    $("#img-content").css({"width": realWidth + 20, "height": realHeight + 20});
                    $("#img-zoom").css({"width": realWidth, "height": realHeight});
                }
                if ((hh - realHeight - 40) > 0) {
                    $("#img-content").css({"top": (hh - realHeight - 40) / 2});
                }
                if ((ww - realWidth - 20) > 0) {
                    $("#img-content").css({"left": (ww - realWidth - 20) / 2});
                }
                $('#img-modal').modal();
            });
        });
    });

    function showhtfun(hturl) {
        window.open("/" + hturl);
    }
</script>